<?php


if(!empty($_POST)){
	if(!empty($_POST['verify'])){
		if(strtolower($_SESSION['Verify'])!=strtolower($_POST['verify'])){
			echo 3;exit;
		};
		unset($_POST['verify']);
	};
  if(!empty($_POST['out'])){
		session_destroy();
		header('location:index.php');exit;
  };
$username=$_POST['loginname'];
$password=md5($_POST['loginpwd']);
$where="`user`='$username' and `pwd`='$password'";
$row=getlist('user',$where);
	if(!empty($row)){	
		if($row[0]['check']==1){	
			$_SESSION['user']=$row;
				if($_POST['rem']==1){
				setcookie('loginname',"$username",time()+60*60*2,'/');
				setcookie('loginpwd',$_POST['loginpwd'],time()+60*60*2,'/');
				}else{
					setcookie('loginname','',0,'/');
					setcookie('loginpwd','',0,'/');
					}
			if(!empty($_SERVER['HTTP_X_REQUESTED_WITH'])){
				$data=array('row'=>$row);
				echo json_encode($data);exit;
				}else{
			header('location:index.php');
			}
		}else{ echo 2; }
	}else{echo 1;exit;};
};



view()

?>